using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class MasterFileIdentifierCodeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public MasterFileIdentifierCodeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"CDM","CM0","CM1","CM2","LOC","OM1-OM6","PRA","STF"};
						validVersionCodes[HL7Version.v231] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF"};
						validVersionCodes[HL7Version.v24] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF","CLN","OME"};
						validVersionCodes[HL7Version.v25] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF","CLN","OME","INV"};
						validVersionCodes[HL7Version.v251] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF","CLN","OME","INV"};
						validVersionCodes[HL7Version.v26] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF","CLN","OME","INV"};
						validVersionCodes[HL7Version.v27] = new string[]{"CDM","CMA","CMB","LOC","OMA","OMB","OMC","OMD","PRA","STF","CLN","OME","INV"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Charge description master file (see Chapter 6, Appendix)","Clinical study master","Clinical study phase master","Clinical study Data Schedule Master","Location master file (see Chapter 3, Appendix)","Observation text master file segments (e.g., Lab) (see Chapter 87, Appendix B):","Practitioner master file (see Chapter 8, Appendix)","Staff Master File (see Chapter 8, Appendix)"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file","Clinic master file","Other basic observation/service attributes"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file","Clinic master file","Other Observation/Service Item master file","Inventory master file"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file","Clinic master file","Other Observation/Service Item master file","Inventory master file"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file","Clinic master file","Other Observation/Service Item master file","Inventory master file"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Charge description master file","Clinical study with phases and scheduled master file","Clinical study without phases but with scheduled master file","Location master file","Numerical observation master file","Categorical observation master file","Observation batteries master file","Calculated observations master file","Practitioner master file","Staff master file","Clinic master file","Other Observation/Service Item master file","Inventory master file"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
